@extends('admin.layout.index')

@section('content')
@if (count($errors) > 0)
    <div class="mws-form-message warning">
      验证失败
        <ul>
            @foreach ($errors->all() as $error)
                <li>{{ $error }}</li>
            @endforeach
        </ul>
    </div>
@endif
<form action="{{url('admin/config/changcontent')}}" method="post">
{{csrf_field()}}
<div class="mws-panel grid_8">
  <div class="mws-panel-header">
    <span>
      <i class="icon-table"></i>{{$title}}</span>
  </div>
  <div class="mws-panel-body no-padding">
    <table class="mws-table">
      <thead>
        <tr>
          <th>ID</th>
          <th>标题</th>
          <th>名称</th>
          <th>内容</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
      @foreach($data as $v)
        <tr>
          <td class="tc">{{$v->conf_id}}</td>
          <td>
              <a href="#">{{$v->conf_title}}</a>
          </td>
          <td>
              <a href="#">{{$v->conf_name}}</a>
          </td>
          <td>

              <input type="hidden" name="conf_id[]" value="{{$v->conf_id}}">
              <a href="#">{!! $v->conf_contents !!}</a>
          </td>
          <td width="170px">
             <a class="btn btn-warning" href="javascript:void(0)" onclick="delConfig({{$v->conf_id}})">删除</a>　
            <a class="btn btn-info" href="{{url('admin/config/'.$v->conf_id.'/edit')}}">修改</a>
          </td>
      </tr>
      
      @endforeach
      </tbody>
    </table>
      <div class="mws-panel-header">
          <th></th>
          <td colspan="5">
              <input type="submit" value="提交">
              <input type="button" class="back" onclick="history.go(-1)" value="返回">
          </td>
      </div>
  </div>
</div>
</form>

<script>
        function delConfig($id){

            layer.confirm('是否确认删除？', {
                btn: ['确认','取消'] //按钮
            }, function(){
                //            jQuery.post(url,data,success(data, textStatus, jqXHR),dataType)
                $.post('{{url('admin/config/')}}/'+$id,{'_token':'{{csrf_token()}}','_method':'delete'},function(data){
                    //console.log(data);
//                    删除成功
                    if(data.status == 0){
                        layer.msg(data.msg, {icon: 6});
                        location.href = location.href;
                    }else{
                        layer.msg(data.msg, {icon: 5});
                        location.href = location.href;
                    }
                });

            });
        }

      </script>
@endsection